package com.yeyuanqi.hottop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeyuanqi.hottop.entity.SysWeb;
import com.yeyuanqi.hottop.entity.TBaiduhot;
import com.yeyuanqi.hottop.mapper.SysWebMapper;
import com.yeyuanqi.hottop.mapper.TBaiduhotMapper;
import com.yeyuanqi.hottop.service.TBaiduhotService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeyuanqi.hottop.vo.HotListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yeyuanqi
 * @since 2021-12-22
 */
@Service
@Transactional
public class TBaiduhotServiceImpl extends ServiceImpl<TBaiduhotMapper, TBaiduhot> implements TBaiduhotService {

    @Autowired
    private TBaiduhotMapper tBaiduhotMapper;
    @Autowired
    SysWebMapper sysWebMapper;


    //查询最新的热搜
    @Override
    public List<HotListVO> selectNewHot() {
        List<HotListVO> newlist = tBaiduhotMapper.selectNewHot();
        //反转列表
        Collections.reverse(newlist);
        return newlist;
    }

    //根据日期或者时间查询热搜
    @Override
    public List<HotListVO> selectHotByTime(String day, String min) {
        List<HotListVO> tBaiduhots = tBaiduhotMapper.selectHotByTime(day, min);
        return tBaiduhots;
    }
}
